<?php
    include '../model/db.php';
    include '../model/fn.php';
    if($_POST['id']){
        $upd=array();
        if($_POST['jpid']!='0'){
            $upd['pid']=$_POST['pid'];
        }
        $upd['name']=$_POST['name'];
        if(db_upd('bl_class',$upd,"id='{$_POST['id']}'")){
            exit("<script>alert('修改成功');location.href='./catelist.php'</script>");
        }else{
            exit("<script>alert('修改失败');location.href='./catelist.php'</script>");
        }
    }
    $id=$_GET['id'];
    if(empty($id)){
        exit("<script>alert('非法请求');location.href='./catelist.php'</Script>");
    }
    $sql="select * from bl_class where id='$id'";
    $arr=db_sel($sql);
    $sql="select * from bl_class where pid=0";
    $list=db_sel($sql,2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>后台 管理中心 - 修改分类 </title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../public/admin/styles/general.css" rel="stylesheet" type="text/css" />
<link href="../public/admin/styles/main.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h1>
<span class="action-span"><a href="catelist.php">商品分类</a></span>
<span class="action-span1"><a href="#">后台 管理中心</a> </span><span id="search_id" class="action-span1"> - 修改分类</span>
<div style="clear:both"></div>
</h1>

<div class="main-div">
  <form action="./cateupd.php" method="post" name="theForm" enctype="multipart/form-data">
  <table width="100%" id="general-table">
      <tr>
        <td class="label">分类名称:</td>
        <td>
          <input type='text' name='name' maxlength="20" value="<?php echo $arr['name'] ?>" size='27' /> <font color="red">*</font>
        </td>
      </tr>
      <tr>
        <td class="label">上级分类:</td>
        <td>
          <select name="pid">
              <option value="0">无</option>
              <?php foreach($list as $v){ ?>
              <option <?php if($v['id']==$arr['pid']){echo 'selected';} ?> value="<?php echo $v['id']; ?>">
                  <?php echo $v['name']; ?>
              </option>
              <?php } ?>
          </select>
            <input type="hidden" name="id" value="<?php echo $arr['id']; ?>">
            <input type="hidden" name="jpid" value="<?php echo $arr['pid']; ?>">
        </td>
      </tr>
      </table>
      <div class="button-div">
        <input type="submit" value=" 确定 " />
        <input type="reset" value=" 重置 " />
      </div>

  </form>
</div>

<div id="footer">
共执行 3 个查询，用时 0.021687 秒，Gzip 已禁用，内存占用 2.081 MB<br />
版权所有 &copy; 2005-2010 上海商派网络科技有限公司，并保留所有权利。</div>

</body>
</html>